<?php
session_start();
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
global $table_prefix, $wpdb;
$citta = $_GET['citta'];
$_SESSION['citta']=$citta;

?>
<li>
    <?php 
    
    $q = "SELECT term_id
		FROM ".$table_prefix."terms
		WHERE name = '$citta'";
    $r = $wpdb->get_results($q);
    $cat = "";
    foreach($r as $id)
    { 
	if($cat=="") $cat = $id->term_id;
	else $cat .="," . $id->term_id;
     }
     if($cat!="") {
    $custom_query = new WP_Query('cat='.$cat); 
while($custom_query->have_posts()) : $custom_query->the_post(); ?>


      <div class="scroll-film">
                            

                            <div class="scroll-thumb"><a href="<?php the_permalink(); ?>"><img src="<?php echo catch_that_image() ?>"></a></div>
                            
                            <div class="scroll-film-toolbar clearfix">
                                
                                

 
                            </div>

                        </div>


<?php endwhile; ?>
<?php wp_reset_postdata(); ?>

<?php
}

$q = "SELECT A.term_id
	FROM ".$table_prefix."terms as A, ".$table_prefix."cittavicine as B, ".$table_prefix."term_taxonomy as C
	WHERE A.name = B.cittaVicina AND B.citta = '$citta' AND A.term_id = C.term_id 
	";
$r = $wpdb->get_results($q);
foreach($r as $near) {

	$idN = $near->term_id;
	$risposta = "<div class='tab_content' style='display: block;'>";
	$custom_query = new WP_Query("cat=$idN &post_per_page=4"); 
	while($custom_query->have_posts()) : $custom_query->the_post(); ?>
		<div class="scroll-film">
                            

                            <div class="scroll-thumb"><a href="<?php the_permalink(); ?>"><img src="<?php echo catch_that_image() ?>"></a></div>
                            
                            <div class="scroll-film-toolbar clearfix">
                                
                                

 
                            </div>

                        </div>	
	<?php 
	endwhile;
	wp_reset_postdata();
}
?>



